package impl

import (
	"github.com/starmotioncf/soutchatinternal/repository"
	"github.com/starmotioncf/soutchatinternal/service"
)

type sensitiveService struct {
	*service.Service
	sensitiveRepo repository.SensitiveRepository
}

func NewSensitiveService(s *service.Service, sensitiveRepo repository.SensitiveRepository) service.SensitiveService {
	_s := &sensitiveService{
		Service:       s,
		sensitiveRepo: sensitiveRepo,
	}
	// _s.init()
	return _s
}

// GetResources 给客户端提供敏感词资源
// func (s *sensitiveService) GetResources(ctx context.Context, rgn region.Region, version string, lang string) (string, string, error) {
// 	resMap := make(map[constant2.SensitiveLevel][]string)
// 	err := s.sensitiveRepo.Foreach(ctx, func(v *model.VcSensitiveWord) error {
// 		if resMap[v.Level] == nil {
// 			resMap[v.Level] = []string{strings.Trim(v.Content, " ")}
// 		} else {
// 			resMap[v.Level] = append(resMap[v.Level], strings.Trim(v.Content, " "))
// 		}
// 		return nil
// 	})
// 	if err != nil {
// 		return "", "", err
// 	}
// 	res := make([]*dto.SensitiveItem, 0)
// 	for level, list := range resMap {
// 		res = append(res, &dto.SensitiveItem{
// 			Level: level,
// 			List:  list,
// 		})
// 	}
// 	slices.SortFunc(res, func(a, b *dto.SensitiveItem) int {
// 		if a.Level > b.Level {
// 			return -1
// 		}
// 		if a.Level < b.Level {
// 			return 1
// 		}
// 		return 0
// 	})
// 	_bb, err := json.Marshal(res)
// 	v := fmt.Sprintf("%x", md5.Sum(_bb))
// 	if v == version {
// 		return v, "", nil
// 	}
// 	return v, string(_bb), err
// }
